package com.tencent.iov.cowin.befsale.clue.controller.cus.assembler;

import com.tencent.iov.cowin.befsale.clue.controller.cus.vo.request.AddOemCustomerRequest;
import com.tencent.iov.cowin.befsale.clue.controller.cus.vo.request.UpdateCustomerRequest;
import com.tencent.iov.cowin.befsale.clue.controller.cus.vo.response.CustomerResponse;
import com.tencent.iov.cowin.befsale.clue.domain.cus.po.CustomerExt;
import com.tencent.iov.cowin.befsale.clue.domain.cus.po.OemCustomer;
import com.software.boot.common.model.dao.BaseAssembler;
import com.software.boot.common.model.rest.BaseRequest;
import com.software.boot.common.model.rest.BaseResponse;
import com.software.common.config.SearchLocalHeader;
import com.software.common.enums.DeleteEnum;
import com.software.common.enums.SCRMRequestHeaderEnum;
import lombok.extern.slf4j.Slf4j;

import java.util.Date;

/**
 * @Author: xiamu
 * @Date: 2021-12-21 18:37:29
 * @Description: 总部客户表主表+客户好友关联表适配器，负责vo<->entity、vo<->po的转换和必要的参数检查，行为
 */
@Slf4j
public class OemCustomerAssembler extends BaseAssembler<BaseResponse, BaseRequest, OemCustomer> {
    public static AddOemCustomerRequest initAddOemCustomerRequest(AddOemCustomerRequest request) {
        request.setCorpId(SearchLocalHeader.getHeader(SCRMRequestHeaderEnum.HEADER_CORP_ACCOUNTID.getCode()));
        request.setTenantId(SearchLocalHeader.getHeader(SCRMRequestHeaderEnum.HEADER_TENANTID.getCode()));
        request.setCreatedBy(SearchLocalHeader.getHeader(SCRMRequestHeaderEnum.HEADER_EMP_ID.getCode()));
        request.setCreatedName(SearchLocalHeader.getHeader(SCRMRequestHeaderEnum.HEADER_EMP_NAME.getCode()));
        request.setDeleted(DeleteEnum.INIT.getFlag());
        request.setCreatedTime(new Date());
        request.setUpdatedTime(new Date());
        return request;
    }

    public static UpdateCustomerRequest initUpdateOemCustomerRequest(UpdateCustomerRequest request) {
        request.setUpdatedBy(SearchLocalHeader.getHeader(SCRMRequestHeaderEnum.HEADER_EMP_ID.getCode()));
        request.setUpdatedName(SearchLocalHeader.getHeader(SCRMRequestHeaderEnum.HEADER_EMP_NAME.getCode()));
        return request;
    }

    public static void initCustomerResponse(CustomerResponse customerResponse, CustomerExt customerExt) {
        customerResponse.setEducation(customerExt.getEducation());
        customerResponse.setFamilyNum(customerExt.getFamilyNum());
        customerResponse.setChildrenNum(customerExt.getChildrenNum());
        customerResponse.setVocation(customerExt.getVocation());
        customerResponse.setFamilyYearIncome(customerExt.getFamilyYearIncome());
        customerResponse.setFamilyYearOutcome(customerExt.getFamilyYearOutcome());
    }
}
